
package org.zfes.snowier.cloud.zbss.cms.column.service;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.core.util.ZAssert;
import org.springframework.web.multipart.MultipartFile;
import org.zfes.snowier.cloud.zbss.cms.column.dto.CmsColumnCreateDto;
import org.zfes.snowier.cloud.zbss.cms.column.model.CmsColumn;
import org.zfes.snowier.cloud.zbss.cms.model.dto.CmsModelDto;
import org.zfes.snowier.cloud.zbss.cms.model.model.CmsModelItem;
import org.zfes.snowier.cloud.zbss.cms.zconfig.ZConfig;
public interface ICmsColumnService{

	 Optional<CmsColumn> loadCmsColumnById(Long id);
	 
	 List<CmsColumn> loadCmsColumn();
	
	 void createCmsColumn(CmsColumnCreateDto columnCreateDto,Map<String ,String> userDefineAttrMap);
	
	 public Long createCmsColumn(CmsColumn cmsColumn) ;
	 
	 void updateCmsColumn(Long columnID,CmsColumnCreateDto columnCreateDto,Map<String ,String> userDefineAttrMap);

	 void updateCmsColumn(CmsColumn column);
	
	 Map<String,List<CmsColumn>> loadColumnIdSubscribeAndNot(Long userId);
	 
	 void deleteCmsColumn(Long id);
	
	 DataSet loadCmsColumnDataSet(Map<String, Object> params);
	 
	 List<Long>loadColumnIdByIsDefault(Byte isDefault);
	 
	 
	 
	 void updateCmsColumnSortNum(Long  columnId,int sortNum);

 	void setCmsColumnStatus(Long id, Byte status);
 	
 	
 	default void validateByModel(CmsModelDto cmsModelDto,CmsColumn cmsColumn,Map<String ,String> userDefineAttrMap) {
		
 		//取出该模型下用户自定义字段列表
 		List<CmsModelItem> modelItemList = cmsModelDto.getCmsModelItemList();
		
 		//查看用户自定义的必填字段是否已填写
 		for(int i=0;i<modelItemList.size();i++) {
 			if(modelItemList.get(i).getIsRequired().equals(Byte.valueOf("1"))&&modelItemList.get(i).getIsColumn().equals(Byte.valueOf("1"))) {
 				ZAssert.isTrue(userDefineAttrMap.containsKey(modelItemList.get(i).getFieldLabel()), "请填写必填项");
 			}
 		}
 		
	}
 	
}